﻿using System.Collections;

namespace genericsvsobjects
{
    public class DataClassCollection : IEnumerator, IEnumerable
    {
        private ArrayList _list;
        private int _current;

        public DataClassCollection()
        {
            _list = new ArrayList();
            Reset();
        }

        public void Add(object dataClass)
        {
            _list.Add(dataClass);
        }

        public bool MoveNext()
        {
            if (_current < _list.Count - 1)
            {
                _current++;
                return true;
            }
            return false;
        }

        public void Reset()
        {
            _current = -1;
        }

        public object Current
        {
            get { return _list[_current]; }
        }

        public IEnumerator GetEnumerator()
        {
            return this;
        }
    }
}